<?php

/**
*  代码下载
*/

class Home{
	function Home($db){
		$this->oDB = $db;
	}
	
	
	
	/**
	*  添加首页图片新闻
	*/
	function insertManual($data,$check=''){
		//重复效验
		if (is_array($check)){
			unset($k,$v);
			foreach ($check AS $k=>$v) {
				$w[] = "`$k`='$v'";
			}
			$ck = $this->oDB->rows("SELECT count(*) AS cnt FROM manual_more WHERE ".implode(' AND ',$w));
			
			//如果存在则提示
			if ($ck[cnt]>=1){
				return false;
			}
		}
		
		return $this->oDB->insert("manual_more",$data);
	}
	/**
	*  更新首页图片新闻
	*/
	function updateManual($data,$where){
		return $this->oDB->update("manual_more",$data,$where);
	}	
	
	/**
	*  获得首页图片新闻文件列表
	*/
	function getListManual($where=''){
		$sql = "SELECT * FROM manual_more $where ORDER BY id DESC";
		return $this->oDB->query($sql);
	}
	
	
	/**
	*  获取首页图片新闻详细信息
	*/
	function getInfoManual($id){
		return $this->oDB->rows("SELECT * FROM manual_more WHERE id='$id'");
	}
	
	
	/**
	*  删除资料
	*	id 		删除数据id
	*	filedir 删除文件文件夹
	*/
	function delManual($id){
		return $this->oDB->query("DELETE FROM manual_more WHERE id='$id'");
	}
	
	
	/**
	*  添加首页图片新闻
	*/
	function insertPAD($data,$check=''){
		//重复效验
		if (is_array($check)){
			unset($k,$v);
			foreach ($check AS $k=>$v) {
				$w[] = "`$k`='$v'";
			}
			$ck = $this->oDB->rows("SELECT count(*) AS cnt FROM home_photo_ad WHERE ".implode(' AND ',$w));
			
			//如果存在则提示
			if ($ck[cnt]>=1){
				return false;
			}
		}
		
		return $this->oDB->insert("home_photo_ad",$data);
	}
	/**
	*  更新首页图片新闻
	*/
	function updatePAD($data,$where){
		return $this->oDB->update("home_photo_ad",$data,$where);
	}	
	
	/**
	*  获得首页图片新闻文件列表
	*/
	function getListPAD($where=''){
		$sql = "SELECT * FROM home_photo_ad $where ORDER BY id DESC";
		return $this->oDB->query($sql);
	}
	
	
	/**
	*  获取首页图片新闻详细信息
	*/
	function getInfoPAD($id){
		return $this->oDB->rows("SELECT * FROM home_photo_ad WHERE id='$id'");
	}
	
	
	/**
	*  删除资料
	*	id 		删除数据id
	*	filedir 删除文件文件夹
	*/
	function delPAD($id){
		
		//获得数据
		$info = $this->getInfoPAD($id);
		//删除附件
		if (trim($info[attach])){
			@unlink($filedir.$info[attach]);
		}
		
		return $this->oDB->query("DELETE FROM home_photo_ad WHERE id='$id'");
	}
	
	/**
	*  添加首页推荐软件
	*/
	function insertSoft($data,$check=''){
		//重复效验
		if (is_array($check)){
			unset($k,$v);
			foreach ($check AS $k=>$v) {
				$w[] = "`$k`='$v'";
			}
			$ck = $this->oDB->rows("SELECT count(*) AS cnt FROM home_soft WHERE ".implode(' AND ',$w));
			
			//如果存在则提示
			if ($ck[cnt]>=1){
				return false;
			}
		}
		
		return $this->oDB->insert("home_soft",$data);
	}
	/**
	*  更新首页推荐软件
	*/
	function updateSoft($data,$where){
		return $this->oDB->update("home_soft",$data,$where);
	}	
	
	/**
	*  获得文件首页推荐软件列表
	*/
	function getListSoft($where=''){
		$sql = "SELECT * FROM home_soft $where ORDER BY id DESC";
		return $this->oDB->query($sql);
	}
	
	
	/**
	*  获取首页推荐软件详细信息
	*/
	function getInfoSoft($id){
		return $this->oDB->rows("SELECT * FROM home_soft WHERE id='$id'");
	}
	
	/**
	*  删除资料
	*	id 		删除数据id
	*	filedir 删除文件文件夹
	*/
	function delSoft($id){
		return $this->oDB->query("DELETE FROM home_soft WHERE id='$id'");
	}
	
	
	
	/**
	*  添加友情连接
	*/
	function insertLink($data,$check=''){
		//重复效验
		if (is_array($check)){
			unset($k,$v);
			foreach ($check AS $k=>$v) {
				$w[] = "`$k`='$v'";
			}
			$ck = $this->oDB->rows("SELECT count(*) AS cnt FROM interested WHERE ".implode(' AND ',$w));
			
			//如果存在则提示
			if ($ck[cnt]>=1){
				return false;
			}
		}
		
		return $this->oDB->insert("interested",$data);
	}
	/**
	*  更新友情连接
	*/
	function updateLink($data,$where){
		return $this->oDB->update("interested",$data,$where);
	}	
	
	/**
	*  获得文件友情连接列表
	*/
	function getListLink($where=''){
		$sql = "SELECT * FROM interested $where ORDER BY id DESC";
		return $this->oDB->query($sql);
	}
	
	
	/**
	*  获取友情连接详细信息
	*/
	function getInfoLink($id){
		return $this->oDB->rows("SELECT * FROM interested WHERE id='$id'");
	}
	
	/**
	*  删除资料
	*	id 		删除数据id
	*	filedir 删除文件文件夹
	*/
	function delLink($id){
		return $this->oDB->query("DELETE FROM interested WHERE id='$id'");
	}
	
	
	
}

?>